﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace skvote
{
    public partial class admin_subject_modify : System.Web.UI.Page
    {
        private OleDbConnection connection = new conn().CreateConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
            function.check();
            string id = Request["id"].ToString();
            try
            {
                OleDbCommand OleCmd = new OleDbCommand("SELECT [Subject],[qx] FROM XH_Subject WHERE [ID]=" + id, connection);
                OleDbDataReader OleDr = OleCmd.ExecuteReader();
                while (OleDr.Read())
                {
                    subject.Text = OleDr.GetString(0).Trim();
                    qx.Text = OleDr.GetDateTime(1).ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);                        
                }
            }
            finally
            {
                connection.Close();
            }
        }

        protected void save_Click(object sender, EventArgs e)
        {
            string id = Request["id"].ToString();
            if (id == null || id == string.Empty)
            {
                function.showErr("参数值为空",Response,Request);
            }            
            try
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                OleDbCommand OleCmd = new OleDbCommand("UPDATE XH_Subject SET [Subject]=\"" + function.nohtml(subject.Text.Trim()) + "\",[qx]=\"" + function.nohtml
                (qx.Text.Trim()) + "\" WHERE [ID]=" + id, connection);
                OleCmd.ExecuteNonQuery();
                OleCmd.Dispose();
            }
            finally
            {
                connection.Close();
            }
            function.successMsg("主题修改成功");
        }
    }
}
